import { createI18n } from 'vue-i18n';
import en from './en-US';
import cn from './zh-CN';

const localeKey = 'arco-locale';

export const LOCALE_OPTIONS = [
	{ label: '中文', value: 'zh-CN' },
	{ label: 'English', value: 'en-US' },
];

const defaultLocale = localStorage.getItem(localeKey) || 'zh-CN';

const i18n = createI18n({
	locale: defaultLocale,
	fallbackLocale: 'en-US',
	legacy: false,
	allowComposition: true,
	messages: {
		'en-US': en,
		'zh-CN': cn,
	},
});

export function setupI18n(app) {
	app.use(i18n);
}
